//
//  RecordTableViewCell.m
//  Rail
//
//  Created by hychen on 2018/2/26.
//  Copyright © 2018年 Hychen. All rights reserved.
//

#import "RecordTableViewCell.h"

@interface RecordTableViewCell ()
@property (weak, nonatomic) IBOutlet UIImageView *iconView;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *descLabel;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;


@end

@implementation RecordTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    [self showBottomLineWithPaddingX:15 color:nil];
    [self showArrowWithImage:nil];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setModel:(id)model
{
    _model = model;
    
    //赋值
    if ([model isKindOfClass:[DeviceFavModel class]]) {
        DeviceFavModel *deviceModel = (DeviceFavModel *)model;
        [self.iconView sd_setImageWithURL:[NSURL URLWithString:deviceModel.logo_url] placeholderImage:ImageNamed_bb(@"app_area_list_default_facility_img")];
        self.titleLabel.text = deviceModel.device_name;
        self.descLabel.text = [WarnLevelConfig deviceStatusString:deviceModel.status];
        self.descLabel.textColor = deviceModel.status == DeviceStatusOnline?Color_RGB(0, 193, 224):ColorDefalutGray;
    }
//    else if ([model isKindOfClass:[SelectVideoDeviceModel class]]) {
//        WatchHistoryModel *watchModel = (WatchHistoryModel *)model;
//        [self.iconView sd_setImageWithURL:[NSURL URLWithString:watchModel.logo_url] placeholderImage:ImageNamed_bb(@"app_area_list_default_facility_img")];
//        self.titleLabel.text = watchModel.device_name;
//#warning 设备状态还未定 先不写
//    }
    else if ([model isKindOfClass:[DeviceStatusModel class]]) {
        DeviceStatusModel *deviceModel = (DeviceStatusModel *)model;
#warning 图片
        self.titleLabel.text = deviceModel.device_name;
        self.descLabel.textColor = deviceModel.status == DeviceStatusOnline?Color_RGB(0, 193, 224):ColorDefalutGray;
        self.descLabel.text = [WarnLevelConfig deviceStatusString:deviceModel.status];
    }
    else if ([model isKindOfClass:[SelectVideoDeviceModel class]]) {
        SelectVideoDeviceModel *deviceModel = (SelectVideoDeviceModel *)model;
        [self.iconView sd_setImageWithURL:[NSURL URLWithString:deviceModel.logo_url] placeholderImage:ImageNamed_bb(@"app_area_list_default_facility_img")];
        self.titleLabel.text = deviceModel.device_name;
        self.descLabel.text = [WarnLevelConfig deviceStatusString:deviceModel.status];
        self.descLabel.textColor = deviceModel.status == DeviceStatusOnline?Color_RGB(0, 193, 224):ColorDefalutGray;
        self.timeLabel.text = [BMUtils formatTimeWithServiceTime:deviceModel.watch_time];
    }
}

@end
